package com.hengxinguotong.zhihuichengjian.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.hengxinguotong.zhihuichengjian.R;
import com.hengxinguotong.zhihuichengjian.bean.Company;
import com.hengxinguotong.zhihuichengjian.widget.font.HXTextView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/3/29.
 */

public class CompanyAdapter extends BaseAdapter {
    private List<Company> datas;
    private Context context;
    private int select = -1;

    public CompanyAdapter(Context context, List<Company> datas) {
        this.context = context;
        this.datas = datas;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null || convertView.getTag() == null) {
            convertView = LayoutInflater.from(context)
                    .inflate(R.layout.item_company, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        Company company = datas.get(position);
        switch (company.getType()){//类型 1:专业工程分包公司；2:劳务分包公司; 3:租赁公司
            case 1:
                holder.companyType.setText("专业工程分包公司");
                break;
            case 2:
                holder.companyType.setText("劳务分包公司");
                break;
            case 3:
                holder.companyType.setText("租赁公司");
                break;
            case 4:
                holder.companyType.setText("建设单位");
                break;
            case 5:
                holder.companyType.setText("施工单位");
                break;
            case 6:
                holder.companyType.setText("监理单位");
                break;

        }
        holder.companyName.setText(company.getName());
        return convertView;
    }


    static class ViewHolder {
        @BindView(R.id.company_name)
        HXTextView companyName;
        @BindView(R.id.company_type)
        HXTextView companyType;
        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
